<?php

namespace App\Console\Commands;

use App\Interfaces\Express;
use App\OrderPay;
use App\Repositories\CouponRepository;
use App\User;
use Carbon\Carbon;
use Illuminate\Console\Command;

class UpdateExpress extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'express:do';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '批量更新物流状态';
    protected  $express;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(Express $express)
    {
        $this->express=$express;
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

/*        OrderPay::where('pay_status',1)->where('mail_no','!=','')->where('ship_status',OrderPay::SHIP_STATUS_DELIVERED)->chunk(10,function($order){
            foreach ($order as $v){
                \Log::info($v->order_pay_id);
                $this->express->expressQueryAsync($v->mail_no);
            }
            \Log::info('物流状态更新,'.Carbon::now());
        });*/
      $coupon=  new CouponRepository();
      for($i=828;$i<=832;$i++){
          $coupon->sendOne(User::find($i),1);
          $this->info($i.'发放成功');
      }

    }
}
